- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » function sum does not work:...
function sum does not work: {sum(myArray[1:i]) for i in 1:dimensions}
function sum does not work: {sum(myArray[1:i]) for i in 1:dimensions}
hello,
just realized that the following statement does not work, although it should:
Code:
model OMtest
parameter Integer dimensions = 5;
parameter Real myArray[dimensions] = {1,2,3,4,5};
parameter Real mySumArray[dimensions] = {sum(myArray[1:i]) for i in 1:dimensions};
end OMtest;
following error:
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:1
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:2
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:3
[SimCodeC.tpl:5647:11-5647:11:writable] Error: Template error: ASUB_EASY_CASE 1:4
where is actually the official OM bug list? I mean it doesnt make sense if I remind you of bugs that are already known and somewhere reported for being fixed... .
and who is allowed to modify this list?
thanks
Re: function sum does not work: {sum(myArray[1:i]) for i in 1:dimensions}
Fun bug
The link to the issue tracker is below, and I don't think I've seen this issue with sum-reductions before:
http://openmodelica.org:8080/cb/proj/tr … acker_id=1
Anyone registered to the codebeamer should be able to post bug reports.
- sjoelund.se
- 1700 Posts
Re: function sum does not work: {sum(myArray[1:i]) for i in 1:dimensions}
hello,
just updated to revision 10901 and tried my test model from above. I am afraid, it doesnt work, although it should since r10870?
following output:
OMtest.c: In function ‘eqFunction_0’:
OMtest.c:168:63: error: expected expression before ‘:’ token
OMtest.c: In function ‘eqFunction_1’:
OMtest.c:177:63: error: expected expression before ‘:’ token
OMtest.c: In function ‘eqFunction_2’:
OMtest.c:186:63: error: expected expression before ‘:’ token
OMtest.c: In function ‘eqFunction_3’:
OMtest.c:195:63: error: expected expression before ‘:’ token
OMtest.c: In function ‘eqFunction_4’:
OMtest.c:204:63: error: expected expression before ‘:’ token
Re: function sum does not work: {sum(myArray[1:i]) for i in 1:dimensions}
could you paste lines 168-177 of the file for me? it seems to be a colon instead of semicolon output from some place but it should help if i know what code was generated
- sjoelund.se
- 1700 Posts
Re: function sum does not work: {sum(myArray[1:i]) for i in 1:dimensions}
here lines 165-181
Code:
void eqFunction_0(_X_DATA *data, _OMC_SEED_HACK) {
real_array tmp0;
/*#modelicaLine [/home/fzaversky/workspace/OM/OMtest.mo:12:1-12:82]*/
real_array_create(&tmp0, ((modelica_real*)&($PmyArray)), 1, :);
$PmySumArray$lB1$rB = sum_real_array(&tmp0);
/*#endModelicaLine*/
}
void eqFunction_1(_X_DATA *data, _OMC_SEED_HACK) {
real_array tmp1;
/*#modelicaLine [/home/fzaversky/workspace/OM/OMtest.mo:12:1-12:82]*/
real_array_create(&tmp1, ((modelica_real*)&($PmyArray)), 1, :);
$PmySumArray$lB2$rB = sum_real_array(&tmp1);
/*#endModelicaLine*/
}
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » function sum does not work:...